@REM 合并 hex 文件
@echo off

SETLOCAL
set input_file=%~1

call %g_bat_dir_path%\readini.bat %g_config_file_path% option isMergeBootHexFile isMergeBootHexFile

@if not defined isMergeBootHexFile (
	@echo Warning: .ini file [option: isMergeBootHexFile] does not set param
	exit /B 0
)

@if %isMergeBootHexFile% equ 0 (
	@echo not need merge hex file
	@exit /B 0
)

call %g_bat_dir_path%\readini.bat %g_config_file_path% boot_file hexFilePath hexFilePath
call %g_bat_dir_path%\readini.bat %g_config_file_path% boot_file hexFileName hexFileName

@if not defined hexFilePath (
	@echo Error: .ini file [boot_file: hexFilePath] does not set param
	exit /B -1
)

@if not defined hexFileName (
	@echo Error: .ini file [boot_file: hexFileName] does not set param
	exit /B -1
)

set hexFileName=%hexFileName%.hex

@set /a hexFileEnd=%hexFileAddr%+%hexFileSize%

@set output_file=merge_%input_file%
set input_file_name=%input_file%.hex
set output_file_name=%output_file%.hex

%g_exe_dir_path%\srec_cat.exe %g_obj_dir_path%\%input_file_name% -intel %hexFilePath%\%hexFileName% -intel -o %g_obj_dir_path%\%output_file_name% -intel

@echo %input_file_name% merge %hexFileName% generate %output_file_name%

(endlocal
set %~2=%output_file%
)
ENDLOCAL
exit /B 0